package com.example.txerra.src;

import android.app.Activity;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;

import com.example.txerra.src.DB.DBHelper;

import java.sql.SQLException;


public class Main extends Activity {

    private MyApp app;
   /* private Button btEntrantes;
    private Button btPrimeros;
    private Button btCarnes;
    private Button btPescados;
    private Button btPostres;
    private Button btBebidas;*/

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);

        //Botoien erazagupena
       /*btEntrantes = (Button)this.findViewById(R.id.btEntrantes);
        btPrimeros = (Button)this.findViewById(R.id.btPrimeros);
        btCarnes = (Button)this.findViewById(R.id.btCarnes);
        btPescados = (Button)this.findViewById(R.id.btPescados);
        btPostres = (Button)this.findViewById(R.id.btPostres);
        btBebidas = (Button)this.findViewById(R.id.btBebidas);*/

        app = (MyApp)getApplication();
        app.openDatabase();

        setContentView(R.layout.activity_main);
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu)
    {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item)
    {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings)
            return true;
        return super.onOptionsItemSelected(item);
    }

    protected void onDestroy()
    {
        super.onDestroy();
        //Datu basea ixten dugu
        //app.db.close();
    }

    public void abrirEntrantes(View view)
    {
        Intent intent = new Intent(Main.this, Detail.class);
        intent.putExtra("type", Definitions.ENTRANTES);
        startActivity(intent);
        //finish();
    }

    public void abrirPrimeros(View view)
    {
        Intent intent = new Intent(Main.this, Detail.class);
        intent.putExtra("type", Definitions.PRIMEROS);
        startActivity(intent);
        //finish();
    }

    public void abrirCarnes(View view)
    {
        Intent intent = new Intent(Main.this, Detail.class);
        intent.putExtra("type", Definitions.CARNES);
        startActivity(intent);
        //finish();
    }

    public void abrirPescados(View view)
    {
        Intent intent = new Intent(Main.this, Detail.class);
        intent.putExtra("type", Definitions.PESCADOS);
        startActivity(intent);
        //finish();
    }

    public void abrirPostres(View view)
    {
        Intent intent = new Intent(Main.this, Detail.class);
        intent.putExtra("type", Definitions.POSTRES);
        startActivity(intent);
        //finish();
    }

    public void abrirBebidas(View view)
    {
        Intent intent = new Intent(Main.this, Detail.class);
        intent.putExtra("type", Definitions.BEBIDAS);
        startActivity(intent);
        //finish();
    }

    /*private void setEvents()
    {
        btEntrantes
    }*/
}
